package com.download.backstage.controller;

import com.download.web.entity.BusAdvertising;
import com.download.web.entity.model.Page;
import com.download.web.entity.model.Result;
import com.download.web.service.IAdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/backstage/advertising")
public class AdvertisingController {

    @Autowired
    private IAdvertisingService advertisingService;

    @ResponseBody
    @RequestMapping("/advertisingPage")
    public Page<BusAdvertising> advertisingPage(Integer pageIndex,Integer pageSize){

        return advertisingService.advertisingPages(pageIndex,pageSize);
    }
    @ResponseBody
    @RequestMapping("/addAdvertsing")
    public Result advertisingPage(@RequestBody BusAdvertising advertising){
        return advertisingService.saveAdvertising(advertising);
    }
    @ResponseBody
    @RequestMapping("/updateAdvertising")
    public Result updateAdvertising(@RequestBody BusAdvertising advertising){
        return advertisingService.updateAdvertising(advertising);
    }
    @ResponseBody
    @RequestMapping("/delAdv")
    public Result delAdv(Integer id){
        advertisingService.removeById(id);
        return Result.ok();
    }
    @ResponseBody
    @RequestMapping("/findAdvById")
    public Result findAdvById(Integer id){
        BusAdvertising advertising=advertisingService.getById(id);
        return Result.ok(advertising);
    }


}
